package org.example;

import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * @author liukaihao
 * @date 2025/03/02
 */
@AllArgsConstructor
@NoArgsConstructor
public class Order {
    private int id;
    private String customerId;
    private int status;
    private List<OrderItem> items;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getCustomerId() {
        return customerId;
    }

    public void setCustomerId(String customerId) {
        this.customerId = customerId;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public List<OrderItem> getItems() {
        return items;
    }

    public void setItems(List<OrderItem> items) {
        this.items = items;
    }

    // 求订单下的订单详情的价格总和
    public Double getTotalPrice() {
        return items.stream().mapToDouble(x->x.getPrice()*x.getQuantity()).sum();
    }

}
